package components.scanario.elements
{
	import SEApp.se_app;
	
	import UIFree.uif_component;
	import UIFree.uif_ecomponent;
	
	import components.c_pcomponent;
	import components.scanario.c_scenarioManager;
	import components.scanario.scenaries.c_baseScenario;
	
	import flash.events.Event;
	import flash.events.MouseEvent;
	import flash.geom.Rectangle;

	public class c_controlElem extends c_scenarioElem {
		private var _event		: String;
		private var _control	: uif_ecomponent;
		private var _scenario	: c_scenarioManager;
		private var _curtain	: c_curtain;
		public function c_controlElem(a_scenario: c_baseScenario, a_control: uif_ecomponent, a_description:String, a_event: String=MouseEvent.CLICK) {
			super(a_scenario, a_description);
			_event		= a_event;
			_scenario 	= a_scenario;
			_control 	= a_control;
			_control.addEvent(_event, doEvent);
			showFocusRect();
		}
		
		private function doEvent(e: Event): void {
			_control.removeEventListener(_event, doEvent);
			_scenario.nextElement();
			_curtain.slideHide(function(): void {
				_curtain.dispose();
			});
		}
		
		protected function showFocusRect(): void {
			var app: se_app = _control.app as se_app;
			var topLayer: uif_component = app.layers[app.layers.length - 1];
			_curtain = new c_curtain(topLayer, _control, 'curtain');
		}
	}
}